<div class="section" id="sitemaplist">
	<?php echo $test?>
	<form action="" name="formlist" id="formlist" method="post">
	<div class="section-title">
		<?php echo $this->document->text['text_header_reportinventorybystock']?>
		  <div class="button right">
			<input class="button" type="button" name="print" value="<?php echo $this->document->text['text_printthislist']?>" onclick="printlist()"/>  
			<input class="button" type="button" name="close" value="<?php echo $this->document->text['button_close']?>" onclick="window.close()"/>  
			<input type="hidden" name="display" id="display" value="" />
		</div>
		<div class="clearer">&nbsp;</div>
	</div>
    
    <div class="section-content">
    	<div>
			<b><?php echo $this->document->text['text_stock']?> : </b><select name="search_stock" id="search_stock" style="width:200px"><?php echo $cb_stock?></select>
			&nbsp;&nbsp;
			<b><?php echo $this->document->text['text_datefrom']?> : </b><input type="text" class="text" size="10" name="search_fromdate" id="search_fromdate" value="<?php echo $search_fromdate?>"  /><b><?php echo $this->document->text['text_to']?></b><input type="text" class="text" size="10" name="search_todate" id="search_todate" value="<?php echo $search_todate?>"  />
			<input class="button" value="<?php echo $this->document->text['button_search']?>" type="submit">
		</div>
            <div class="sitemap treeindex" style="width:1000px">
			<?php foreach($reports as $brand) {?>
				<h3>Brand: <?php echo $brand["brandid"]?> - <?php echo $brand["brandname"]?></h3>
				<table class="data-table" cellpadding="0" cellspacing="0">
                <tbody>
                    <tr class="tr-head">
						<th width="30px" rowspan="2">No.</th>
                         <th width="180px" rowspan="2"><?php echo $this->document->text['text_groupname']?></th>
					    <th width="180px" rowspan="2"><?php echo $this->document->text['text_barcode']?></th>
						<th width="210px" rowspan="2"><?php echo $this->document->text['text_productname']?></th>
                        <th width="120px" rowspan="2"><?php echo $this->document->text['text_unit']?></th>
						<th width="120px" rowspan="2"><?php echo $this->document->text['text_startperiod']?></th>
						<th width="240px" colspan="2"><?php echo $this->document->text['text_inperiod']?></th>
						<th width="120px" rowspan="2"><?php echo $this->document->text['text_endperiod']?></th>
						<th width="100px" rowspan="2"><?php echo $this->document->text['text_importcost']?></th>
						<th width="100px" rowspan="2"><?php echo $this->document->text['text_totalcost']?> (<?php echo $this->document->text['text_instock']?>)</th>
                    </tr>
					<tr class="tr-head">
						<th width="120px"><?php echo $this->document->text['text_import']?></th>
						<th width="120px"><?php echo $this->document->text['text_export']?></th>
                    </tr>
					
					<?php					
						foreach($brand['group'] as $group)
						{
					?>
					
							<tr>
								<td colspan="11" style="background-color:#F5F5F5"><b>Group : <?php echo $group['groupid']?> - <?php echo $group['groupname']?></b></td>
							</tr>					
        
        
							<?php
								$index = 0;
								
								foreach($group['items'] as $item)
								{
									
									$index += 1;
							?>
										<tr>
											<td><?php echo $index?></td>
											<td><?php echo $item['groupname']?></td>
											<td><?php echo $item['barcode']?></td>
											<td><?php echo $item['productname']?></td>
											<td><?php echo $item['unit']?></td>
											<td class="calc" style="text-align:right"><?php echo $item['sumstartperiod']?></td>
											<td class="calc" style="text-align:right"><?php echo $item['sumimportqty']?></td>
											<td class="calc" style="text-align:right"><?php echo $item['sumexportqty']?></td>
											<td class="calc" style="text-align:right"><?php echo $item['sumendperiod']?></td>
											<td class="calc" style="text-align:right"><?php echo $item['importcost']?></td>
											<td class="calc" style="text-align:right"><?php echo $item['totalcost']?></td>
										</tr>
							<?php
								}
							?>
					
					
					<?php
						}
					?>
                        
                                                    
                </tbody>
                </table>
			<?php } ?>
			
			
                
            </div>
        
        
        </form>
        
    </div>
    
</div>
<script language="javascript">
$(function() {
		$("#search_fromdate").datepicker({
				changeMonth: true,
				changeYear: true,
				dateFormat: 'dd/mm/yy'
				});
		
		
		$("#search_todate").datepicker({
				changeMonth: true,
				changeYear: true,
				dateFormat: 'dd/mm/yy'
				});		
		
		$(".calc").each(function(){
			num = formateNumber($(this).html().replace(/,/g,""));
			$(this).html(num);
		});
		
		$('.orderlink').popupWindow({ 
			height:600, 
			width:1020, 
			centerScreen:1,
			scrollbars: 1,
			resizable : 1,
			status: 0,
			location: 0
		});
		
		$("#search_brand").change(function(){
			$.post("?route=report/inventory/getcbgroup", 
					$("#formlist").serialize(), 
					function(data)
					{
						if(data!="")
						{
							$("#search_group").html(data);
						}
					}
			);
		});
		
});
		
		

function deleteList1()   
{
	$.post("?route=voucher/search/deleteorder", 
			$("#formlist").serialize(), 
			function(data)
			{
				if(data!="")
				{
					alert(data)
					linkto("?<?php echo $refres?>")
				}
			}
	);
}

function printlist()   
{
	$("#display").val("report");
	$("#formlist").attr("target","_self");
	$("#formlist").submit();
	$("#display").val("report");
	$("#formlist").attr("target","");
}

</script>
